//
//  HTTravelDetailCell.m
//  HeartTravel
//
//  Created by lanou on 15/10/31.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "HTTravelDetailCell.h"
#import "UIImageView+WebCache.h"

@implementation HTTravelDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 20, 20)];
        _timeLabel.textColor = [UIColor lightGrayColor];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        
//        _travelPic = [[UIImageView alloc] init];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = [UIFont systemFontOfSize:12];
        _contentLabel.numberOfLines = 0;
        
        [self.contentView addSubview:_timeLabel];
//        [self.contentView addSubview:_travelPic];
        [self.contentView addSubview:_contentLabel];
    }
    
    return self;
}

- (void)setConfigureModel:(HTWaypointsModel *)configureModel {
    
    _configureModel = configureModel;
    _timeLabel.text = configureModel.local_time;

    _contentLabel.frame = CGRectMake(10, 40, SCREEN_WIDTH - 20, [HTTravelDetailCell heightForString:configureModel.text]);
    _contentLabel.text = configureModel.text;
    
}

+ (CGFloat)heightForString:(NSString *)string {
    
    CGRect bounds = [string boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
    
    return bounds.size.height;
}

+ (CGFloat)heightForCellWithModel:(HTWaypointsModel *)model {
    CGFloat height = 0;
    height = [self heightForString:model.text] + 50;
    
    return height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
